﻿using AutoMapper;
using HamcoWcs.Entitys.BaseConfigs;

namespace HamcoWcs.Models.BaseConfigs
{
    public class UIGlobalConfigModel
    {
        public string Name { get; set; }
        public int DeviceType { get; set; }
        public string Value { get; set; }
        public string Remark { get; set; }
    }

    public class GlobalConfigModel
    {
        public string Name { get; set; }
        public int Offset { get; set; }
        public int Length { get; set; }
        public string Type { get; set; }
        public string Options { get; set; }
        public string CurrentValue { get; set; }
        public bool IsChange { get; set; }
        public string PlcName { get; set; }
        public string PlcType { get; set; }

        public string NewValue
        {
            get => _newValue;
            set
            {
                if (_newValue != value)
                {
                    IsChange = true;
                    _newValue = value;
                }
            }
        }

        private string _newValue = "";
    }

    public class GlobalConfigModelProfile : Profile
    {
        public GlobalConfigModelProfile()
        {
            CreateMap<GlobalConfig, GlobalConfigModel>();
        }
    }
}
